package com.mainworks.commons.exception;

import com.mainworks.commons.UnifyResponse;
import com.mainworks.commons.enums.ResponseCode;

/**
 * 自定义异常
 * @Author: HuangMinJie
 * @CreateDate: 2021/10/31 15:38
 * @Description:
 * @Version: 1.0.0.0
 * @ModifiedBy:
 * @ModifiedDate:
 * @ModifiedDescription:
 */
public class BizException extends RuntimeException{

    protected int code = 400;
    protected String msg;

    public BizException() {
        super();
    }

    public BizException(String msg) {
        super(msg);
        this.msg = msg;
    }


    public BizException(ResponseCode code, String msg) {
        super(msg);
        int status;
        switch (code){
            case FAIL :
                status = UnifyResponse.STATUS_FAIL;
                break;
            case NO_LOGIN:
                status = UnifyResponse.STATUS_NO_LOGIN;
                break;
            case UITra_VIRES:
                status = UnifyResponse.STATUS_UITra_VIRES;
                break;
            case OVERDUE:
                status = UnifyResponse.STATUS_OVERDUE;
                break;
            default: status = UnifyResponse.STATUS_ERROR;
                break;

        }
        this.code = status;
        this.msg = msg;
    }

}